//
//  UIView+Cat.m
//  SportRing
//
//  Created by apple on 14/10/26.
//  Copyright (c) 2014年 HotOne. All rights reserved.
//

#import "UIView+Cat.h"

@implementation UIView (Cat)

- (UIImage *)image
{
    UIImage * image = nil;
    UIGraphicsBeginImageContextWithOptions(self.frame.size, NO, 1.0);  //NO，YES 控制是否透明
    [self.layer renderInContext:UIGraphicsGetCurrentContext()];
    image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    return image;
}

- (void)roundedCornerWithRadius:(CGFloat)cornerRadius
                    borderColor:(UIColor *)borderColor
                    borderWidth:(CGFloat)borderWidth
{
    CGFloat maxRadius = (MIN(CGRectGetWidth(self.bounds), CGRectGetHeight(self.bounds)))/2;
    self.layer.cornerRadius = (maxRadius < cornerRadius ? maxRadius : cornerRadius);
    self.layer.borderColor = [borderColor CGColor];
    self.layer.borderWidth = borderWidth;
    self.clipsToBounds = YES;
}

@end
